import QtQuick 2.0

Item {
    id: btn

    signal clicked

    property string img: ""
    property string text: ""
    property string text2: ""
    property int textSize: 20
    property string textFont: "Verdana"
    property color textColor: "#FF000000"
    property var action
    property int id2: -1
    width: 160
    height: 200

    Column {
        spacing: 0
        Image {
            id: buttonImage
            source: btn.img
            //border { left: 5; top: 5; right: 5; bottom: 5 }
            //horizontalTileMode: BorderImage.Stretch
            //verticalTileMode: BorderImage.Stretch
            width: btn.width
            height: btn.width
            MouseArea {
                id: mouseRegion
                anchors.fill: buttonImage
                onClicked: {
                    btn.clicked();
                    btn.action[0]();
                    // Ugly hack:(
                    if( id2 != -1 ) {
                        myKit.loadSettings(id2);

                    }
                }
            }
        }
        Item {
            width: btn.width
            height: 5
        }
        Text {
            id: buttonText
            color: btn.textColor
            anchors.horizontalCenter: parent.horizontalCenter
            text: btn.text
            font.family: btn.textFont
            font.pointSize: btn.textSize


            MouseArea {
                anchors.fill: parent
                onClicked: {
                    // Ugly hack
                    if( id2 != -1 ) {
                        startSpeechRecognition("editUser", false, buttonText, buttonText, buttonText.color, 2000);
                        buttonText.color = "red";
                    }
                }
            }

        }
        Text {
            id: buttonText2
            color: btn.textColor
            anchors.horizontalCenter: parent.horizontalCenter
            text: btn.text2
            font.family: btn.textFont
            font.pointSize: btn.textSize
        }
    }
}
